package cn.com.geoway.booksystem.controller.houtai;


import cn.com.geoway.booksystem.dao.BookDao;
import cn.com.geoway.booksystem.dao.BookTypeDao;
import cn.com.geoway.booksystem.entity.BookType;
import cn.com.geoway.booksystem.service.BookService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/houtai/book/search")
public class HouTai_BookSearch_Controller {

    @Resource
    private BookDao bookDao;
    @Resource
    private BookService bookService;
    @Resource
    private BookTypeDao bookTypeDao;


    /**
     * /houtai/book/search/manage
     */
    @RequestMapping("/manage")
    public ModelAndView manage() throws Exception {
        ModelAndView mav = new ModelAndView();

        Pageable pageable=new PageRequest(0,100, Sort.Direction.ASC,"orderNo");
        Page<BookType> list = bookTypeDao.findAll(pageable);
        List<BookType> bookTypeList = list.getContent();//拿到list集合
        mav.addObject("bookTypeList", bookTypeList);

        mav.addObject("title", "图书查询");
        mav.setViewName("/admin/page/booksearch/booksearch_manage");
        return mav;
    }
}
